<?php
class Apps_Mail extends Zend_Mail {
	protected $_charset = 'utf-8';

	protected static $_transport = null;
	const TRANSPORT_NO_REPLY = 'no-reply';

	public function __construct($defaultTransport = self::TRANSPORT_NO_REPLY) {
		if(null === self::$_transport) {
			self::$_transport = array(
			     self::TRANSPORT_NO_REPLY => array('GEDDeal.com',
			                             'no-reply@geddeal.com',
			                             new Apps_Mail_Transport_Smtp(array(
			                                 'username' => 'no-reply@geddeal.com',
						                     'password' => 'thanhged123'))
			                             )

            );
		}
		if(null === self::getDefaultTransport()) {
			$d = self::$_transport[$defaultTransport];
			self::setDefaultTransport($d[2]);
			self::setDefaultFrom($d[1], $d[0]);
		}
	}
	/**
	 * @param string|Zend_Zend_Mail_Transport_Abstract $transport
	 * @return Apps_Mail $this
	 */
	public function send($transport = null) {
		if(is_string($transport)) {

			$t = self::$_transport[$transport];

		    $transport = $t[2];

		    if(null !== $this->_from) { $this->setFrom($t[1], $t[0]); }
		}
		return parent::send($transport);

	}

	//reset recipients list to start a new session
	public function clearTo() {
	    return $this->clearRecipients();
	}
}